package com.clothing.customization.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;

/**
 * 服装材质实体类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_clothing_material")
public class ClothingMaterial {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 材质名称
     */
    @Column(nullable = false, length = 50)
    private String name;
    
    /**
     * 材质描述
     */
    @Column(columnDefinition = "LONGVARCHAR")
    private String description;
    
    /**
     * 材质图片URL
     */
    @Column(name = "image_url", length = 255)
    private String imageUrl;
    
    /**
     * 单价
     */
    @Column(precision = 10, scale = 2)
    private BigDecimal price;
    
    /**
     * 库存数量
     */
    @Column
    private Integer stock;
    
    /**
     * 单位
     */
    @Column(length = 20)
    private String unit;
    
    /**
     * 材质成分
     */
    @Column(length = 100)
    private String composition;
    
    /**
     * 适用季节
     */
    @Column(length = 50)
    private String season;
    
    /**
     * 材质特性
     */
    @ElementCollection
    @CollectionTable(name = "tb_material_features", joinColumns = @JoinColumn(name = "material_id"))
    @Column(name = "feature")
    private Set<String> features = new HashSet<>();
    
    /**
     * 状态：1(启用)，0(禁用)
     */
    @Column(nullable = false)
    private Integer status = 1;
    
    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_time", updatable = false)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "update_time")
    private LocalDateTime updateTime;
} 